package com.ketangpai.admin.controller;


import com.ketangpai.admin.entity.dto.SectionDTO;
import com.ketangpai.admin.service.SectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/directory")
@Api(tags = "目录")
public class DirectoryController {
    @Resource
    private SectionService sectionService;


    @ApiOperation("获取所有列表")
    @RequestMapping(method = RequestMethod.GET,value = "/list")
    public List<SectionDTO> getAll() {
        List<SectionDTO>  list = sectionService.getAllDirectories();
        System.out.println(list);
        return list;
    }

    @ApiOperation("根据上级获取列表")
    @RequestMapping(method = RequestMethod.GET,value = "/getParentKey/{parentId}")
    public List<SectionDTO> getParentList(@PathVariable("parentId") Integer parentId){
        System.out.println(parentId);
        List<SectionDTO> list = sectionService.getByParentId(parentId);
        return list;
    }

}
